From 4ea41d00866f1e441c055cc12984b2acc1981658 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 25 Jan 2016 10:41:44 -0800 Subject: [PATCH] Be sure the 'is not a crate root' message shows up --- src/cargo/ops/cargo_install.rs | 12 +++++++----- tests/test_cargo_install.rs | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 8d51d7cd1..57f94f223 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -50,13 +50,15 @@ pub fn install(root: Option<&str>, } else if source_id.is_path() { let path = source_id.url().to_file_path().ok() .expect("path sources must have a valid path"); + let mut src = PathSource::new(&path, source_id, config); + try!(src.update().chain_error(|| { + human(format!("`{}` is not a crate root; specify a crate to \ + install from crates.io, or use --path or --git to \ + specify an alternate source", path.display())) + })); try!(select_pkg(PathSource::new(&path, source_id, config), source_id, krate, vers, - &mut |path| path.read_packages()) - .chain_error(|| human(format!("`{}` is not a crate root; specify a \ - crate to install from crates.io, or \ - use --path or --git to specify an \ - alternate source", path.display())))) + &mut |path| path.read_packages())) } else { try!(select_pkg(RegistrySource::new(source_id, config), source_id, krate, vers, diff --git a/tests/test_cargo_install.rs b/tests/test_cargo_install.rs index 85022ba2c..f5e42c994 100644 --- a/tests/test_cargo_install.rs +++ b/tests/test_cargo_install.rs @@ -120,7 +120,10 @@ could not find `foo` in `registry file://[..]` with version `0.2.0` test!(no_crate { assert_that(cargo_process("install"), execs().with_status(101).with_stderr("\ -Could not find Cargo.toml in `[..]` +`[..]` is not a crate root; specify a crate to install [..] + +Caused by: + Could not find Cargo.toml in `[..]` ")); }); -- 2.30.2